#homework_a
def fn():
    products = [["iphone",6888],["MacPro",14800],["小米6",2499],["Coffee",31],["Book",60],["Nike",699]]
    print("------ 商品列表 ------")
    def foo(x):
        for i in range(len(products)):
            print(*products[i],sep="   ")
    return foo(products)

fn()

#homework_b
def foo():
    products = [["iphone",6888],["MacPro",14800],["小米6",2499],["Coffee",31],["Book",60],["Nike",699]]
    shop_car = []
    shop_cost = []
    nums = [i for i in range(len(products))]

    while True:
        for x,y in enumerate(products):
            print(x,"物品:{}，价格:{}".format(y[0],y[1]))
        need = input("请输入你想要物品的编号,结算就输入 q \n")
        if need == 'q':
            break
        else:
            print("输入正确物品编号啊，智障！") if int(need) not in nums else shop_car.append(products[int(need)][0])
    shop_cost = shop_car
    print(shop_cost)

foo()

# 逻辑上没有啥问题，写的不错